package com.ldf.jrtsp.auth;

import com.ldf.jrtsp.parser.RtspUrlParser;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

import static com.ldf.jrtsp.constants.RtspConstants.RTSP_AUTH_BASIC_HEARD;

/**
 * rtsp base鉴权
 *
 * @author lidaofu
 * @since 2024/6/19
 **/
public class RtspBaseAuth implements IRtspAuth {
    @Override
    public String calcAuthInfo( RtspUrlParser rtspUrlParser, String authInfoOriginal,String method) {
        String authorization = rtspUrlParser.getUsername() + ":" + rtspUrlParser.getPassword();
        return RTSP_AUTH_BASIC_HEARD+Base64.getEncoder().encodeToString(authorization.getBytes(StandardCharsets.UTF_8))+"\r\n";
    }
}
